home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _AAC4B543D1064DADAEC7C433BC3227AB < prev    next >
Text File  |  2005-02-15  |  1KB  |  64 lines

  1. //extrudes an object away from a light, for faces away from the light
  2. //Luke Lenhart
  3. //(C)2004-2005 Digipen Institute of Technology
  4.  
  5. //...shadows depreciated...
  6.  
  7. //world,view,projection transforms
  8. float4x4 matWorld, matViewProj;
  9.  
  10. //light position (in world space)
  11. float4 lightPos;
  12.  
  13. //shader input
  14. struct VS_INPUT
  15. {
  16.     float4 Pos : POSITION;
  17.     float4 Normal : NORMAL;
  18.     //float2 Tex0 : TEXCOORD0;
  19. };
  20.  
  21. //shader output
  22. struct VS_OUTPUT
  23. {
  24.     float4 Pos : POSITION;
  25.     //float2 Tex0 : TEXCOORD0;
  26.     //float4 Color : COLOR;
  27. };
  28.  
  29. //shader code
  30. VS_OUTPUT VShader(VS_INPUT In)
  31. {
  32.     VS_OUTPUT Out;
  33.     
  34.     //move us to world space
  35.     In.Pos.xyz-=In.Normal.xyz*0.25f; //pull in tiny bit so wrong surfaces don't get shadowed
  36.     float4 pos=mul(matWorld,In.Pos);
  37.     float4 norm=mul(matWorld,In.Normal.xyz);
  38.     
  39.     const float EXTRUDE_DIST=10000.0f;
  40.     
  41.     //calc direction from light to vert
  42.     float3 rayDir=normalize(pos.xyz-lightPos.xyz);
  43.         
  44.     //stuff on the back side should be extruded
  45.     float sideCheck=dot(norm,rayDir);
  46.     if (sideCheck>0) //back side
  47.     {        
  48.         //push vert in direction of ray
  49.         pos.xyz+=rayDir*EXTRUDE_DIST;
  50.     }
  51.     
  52.     //calc transformed position
  53.     Out.Pos=mul(matViewProj,pos);
  54.     
  55.     //copy tex coord
  56.     //Out.Tex0=In.Tex0;
  57.     
  58.     //plain color
  59.     //Out.Color=float4(1,1,1,1);
  60.  
  61.     //spit out the results
  62.     return Out;
  63. }
  64.